package org.example.lifecycle;

import org.springframework.beans.factory.BeanNameAware;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class BeanLifeComponent implements BeanNameAware{

    @PostConstruct
    public void postConstruct() {
        System.out.println("执行 PostConstruct()");
    }

    public void init() {
        System.out.println("执行 BeanLifeComponent init-method");
    }

    @PreDestroy
    public void preDestroy() {
        System.out.println("执行：preDestroy()");
    }

    public void setBeanName(String s) {
        System.out.println("执行了 setBeanName 方法：" + s);
    }

}
